import Vue from 'vue'
import store from './store'
import App from './App'
import * as utils from "@/access/utils.js"
import * as common from "@/access/common.js"
import Tabbar from '@/components/Tabbar/index';
import empty from '@/components/empty/index.vue'
Vue.component('Tabbar', Tabbar)
Vue.component('Aempty', empty)
// 数字精度计算
import NP from "number-precision";
Vue.prototype.$NP = NP; // 高精度数学计算
import uView from "uview-ui";
Vue.use(uView);
import goPage from '@/mixin/goPage.js'
const msg = (title, duration = 1500, mask = false, icon = 'none') => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const prePage = () => {
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}

Vue.prototype.$api = {
	msg,
	prePage
};
Vue.mixin(goPage)
Vue.config.productionTip = false
Vue.prototype.$fire = new Vue();
Vue.prototype.$store = store;
Vue.prototype.$api = {
	msg,
	prePage
};
Vue.prototype.$_utils = utils
Vue.prototype.$common = common
App.mpType = 'app'

const app = new Vue({
	...App
})

// http拦截器，将此部分放在new Vue()和app.$mount()之间，才能App.vue中正常使用
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)

// http接口API抽离，免于写url或者一些固定的参数
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
app.$mount()
